<?php

/**
 * Description of News
 *
 * @author NguyenVanTien
 */
class Application_Model_News extends Application_Model_DbTable_News {

    /**
     * sql get list news
     * @author Tien Nguyen
     * @return Zend_Db_Select
     */
    public function getList() {
        $select = $this->select();
        $select->from('news')
                ->where('is_deleted = ?', 0)
                ->where('visible = ?', 1);
        return $select;
    }

    /**
     * Get list last news
     * @author Tien Nguyen
     * @return Zend_Db_Select
     */
    public function getListLastNews() {
        $select = $this->getList();
        $select->order(array('create_date DESC'));
        return $select;
    }

    public function getNews($newsId) {
        
        $select = $this->select()
                ->from('news')
                ->where('is_deleted = ?', 0)
                ->where('visible = ?', 1)
                ->where('news_id = ?', $newsId);
        
        return $this->fetchRow($select);
    }

}